<script src="/public/library/jquery/jquery-tooltip/jquery.tooltip.js" type="text/javascript"></script>
<script src="/public/library/hvn/jquery.svgallery.js" type="text/javascript"></script>
<script src="/public/library/jquery/jquery.translate-1.3.7.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="/public/library/jquery/jquery-tooltip/jquery.tooltip.css" />

<?
	$sess = new Zend_Session_Namespace(CLU_NS);
?>

<script type="text/javascript">
	$(function(){
		bulkModule("bulk-form", "place-row-", "place-status-", "placeIdClass");
		$('a.placeToolTip').tooltip({ 
            track: true, 
            delay: 0, 
            showURL: false, 
            opacity: 1, 
            fixPNG: true, 
//            showBody: " - ", 
            bodyHandler: function() { 
//        		return $($(this).attr("href")).html();
                txt = $(this).parent().find('span.tipSpan').html();
                return txt; 
   			}, 
            fade: 250, 
            extraClass: "nodePreview", 
   		});
	});
	
</script>

	    
<script type="text/javascript">
	$(function() {
	    $('.search-result-item-wrapper').hover(
	        function(){
				$(this).addClass("owners-operation-background").find(".owners-operation span").show();
	         },
	         function(){
	            $(this).removeClass("owners-operation-background").find(".owners-operation span").hide();
	         }
	     );
	     $("span.left-category-image-thumb").svgallery({'animationSpeed' : 500});
	});
	
</script>    
<div class="box white_bg" style="background-color:#ffffff">
<div class="box">
    <div class="vietnam_content" >
	 	<div class="lienket_title" >
			<a href="#"><span><?=t(909)?></span></a>
			<?if(isset($this->viewParams['cityName'])) :?>
				<a href="<?=$this->hvnUrl(array('module'=>'place','action' => 'search'), 'nocontroller')
				?>?cluSearch=1&city_id=<?if(isset($this->viewParams['cityId'])):?><?=$this->viewParams['cityId']?><?endif?>">
				&raquo;
				<?if($sess->viewLang == 'vi')echo $this->viewParams['cityName']; else echo VN_unaccent($this->viewParams['cityName'])?>
				</a>
			<?endif?> 
			
			<a href="<?=$this->hvnUrl(array('module'=>'place','action' => 'search'), 'nocontroller')?>?cluSearch=1
				<?if(isset($this->viewParams['dist_Id'])):?>&district_id=<?=$this->viewParams['dist_Id']?><?endif?>">
				<?if(isset($this->viewParams['districtName'])):?>&nbsp; &raquo; &nbsp;
				<?if($sess->viewLang == 'vi')echo $this->viewParams['districtName']; else echo VN_unaccent($this->viewParams['districtName'])?>
				<?endif?>
			</a>
			
			<?if(isset($this->viewParams['rtype'])):?>
			<a href="<?=$this->hvnUrl(array('module'=>'place','action' => 'search'), 'nocontroller')
				?>?cluSearch=1<?if(isset($this->viewParams['cityId'])):?>&city_id=<?=$this->viewParams['cityId']?><?endif?>
				  &rtype=<?=$this->viewParams['rtype']?>">
				<?if(isset($this->viewParams['categoryName'])) :?>&nbsp; &raquo; &nbsp; <?=p($this->viewParams['categoryName']['name'])?><?endif?></a>
			<?endif?>
			<?if(isset($this->viewParams['typeName'])) :?>&nbsp; &raquo; &nbsp; <?=p($this->viewParams['typeName']['name'])?> <?endif?>
	    </div>
    </div>
</div>

<!-- Old List -->
<? if(isset($this->viewParams['pList']) && count($this->viewParams['pList']) > 0):?>   

<div>
<?
$pageCount = ceil($this->viewParams['paginator']->getTotalItemCount()/$this->viewParams['paginator']->getItemCountPerPage());
?>

<? if ($pageCount > 1) :?>
	<?= $this->paginationControl($this->viewParams['paginator'], 'Sliding', '/modules/common/views/scripts/commonTheme/commonLang/common/clu-pagination-control.phtml',
							    array('searchUrl' => $this->viewParams['searchUrl'])); ?>
<?endif ?>

</div>

<form id ="bulk-form" action="/en/place/ajax/bulk-place" method="POST">
<?$i = 0; //die_a($this->viewParams['pList'])?>
<?foreach ($this->viewParams['pList'] as $place):?>
<?$i++; ?>
<?$metaData = unserialize($place['metadata']);?>

	<div class="catagory_result_list">
          <div class="catagory_result_img">
          <?
          		$thumb = str_replace("/original/","/medium/", $place['thumb']);
          		if(isset($place['thumb']))
	    			$ret = "<img src='$thumb' />";
		    	else
	    			$ret = "<img src='/public/themes/prime/images/common/75x75_no_image.gif' />";
     	  ?>
     		<a href="<?=$this->hvnUrl(array('module' => 'place', 'action' => 'view'))?>?id=<?=$place['id']?>"><?=$ret;?></a>
          </div>
          <?if(isset($this->viewParams['aList'][$place['id']])) :?>
          
          <div class="camnang_heritage_title"><a href="<?=$this->hvnUrl(array('module' => 'place', 'action' => 'view'))?>?id=<?=$place['id']?>">
          	<?=$this->viewParams['aList'][$place['id']]['article_title']?>
          	</a></div>
          <?if(isset($metaData['city_name'])) :?>
	          <div class="catagory_result_add"><b><?=t(777)?></b>
	          	<?=$place['address9'];?> <?=$place['address8'];?> <?=$place['address7'];?> <?=$place['address6']. ', ';?> <?=$place['address5'];?>
	          	<?if(isset($metaData['district_name'])) :?><?//=t(771)?><?=$metaData['district_name'] . ', '?><?endif?> <?=$metaData['city_name']?>
	          </div>
	      <?endif?> 
          <?if(!empty($place['phone'])) :?>
          	<div class="catagory_result_add"><b><?=t(750)?></b> <?=$place['phone']?></div>
          <?endif?>
          <div class="catagory_result_add">
          	<?if(isset($this->viewParams['aList'][$place['id']]['article_body'])) :?><b><?=t(21)?></b> : <?=substring_n_words(strip_tags($this->viewParams['aList'][$place['id']]['article_body']), 40)?><?endif?></div>
          <div class="clear"></div>
          <?else:?>
          <div class="camnang_heritage_title"><a href="<?=$this->hvnUrl(array('module' => 'place', 'action' => 'view'))?>?id=<?=$place['id']?>">
          	<?=$place['name']?>
          	</a></div>
          <div class="catagory_result_add"><b><?=t(777)?></b>
          	<?if(isset($metaData['district_name'])) :?><?=$metaData['district_name'] . ', '?><?endif?> <?=$metaData['city_name']?> 
          </div>
          <?if(isset($place['desc'])) :?>
          	<div class="catagory_result_add">
          		<b><?=t(21)?></b> : <?=substring_n_words(strip_tags($place['desc']), 40)?>
          	</div>
          <?endif?>
          <div class="clear"></div>
          <?endif?>
    </div> 
    <script type="text/javascript">
		var oriLang = '<?=$this->viewParams['aList'][$place['id']]['article_language']?>';
		var lang = '<?= $sess->viewLang?>';
	    googleTranslate(oriLang, lang, 'camnang_heritage_title', 'catagory_result_add');
	</script>
<div class="box_list_events_search">
	<div class="owners-operation"/>
		<span style="display:none">
			<a style="text-decoration:none" href="<?=$this->hvnUrl(array('module' => 'event', 'action' => 'new'))?>?belong_to_ids=<?=$place['id']?>&belong_to_names_submit=<?=$place['name'] ?>"><?=t(221)?></a> |
			<a style="text-decoration:none" href="<?=$this->hvnUrl(array('module' => 'place', 'action' => 'edit'))?>?id=<?=$place['id']?>"><?=t(135)?></a> |
			
				<? $languages =  Zend_Registry::get('configuration')->languages;?>
			<?=t(90)?>: 
			<? foreach ($languages as $k=>$v) :?>
	            <? if ($k != $this->viewParams['aList'][$place['id']]['article_language']) :?> 
	        		<a style="text-decoration:none" href="<?=$this->hvnUrl(array('module' => 'article', 'action' => 'translate'))?>?id=<?=$this->viewParams['aList'][$place['id']]['article_id']?>&to=<?=$k?>"><?=substr(strstr($v,'_'),1)?></a>,
	        	<?endif?>
	        <?endforeach?>
	        
			 | <a style="text-decoration:none"  href="#"> <?=t(32) ?></a>
			 
			<a style="text-decoration:none;color:red"  href="javascript:void()" name="place-delete-<?=$place['id']?>" > [<?=t(31) ?>] </a>
			<span id="delete-error-<?=$place['id']?>"></span>
		</span>
	</div>
</div>
<?if(strpos($sess->userPermissions, "update place")) :?>
	<div style="float:right;">
		<a href="<?=$this->hvnUrl(array('module' => 'place', 'action' => 'edit'))?>?id=<?=$place['id']?>"><?=t(38) ?></a>
	</div>
	<div class="clear"></div>
<?endif?>
<?endforeach?>


<div>
<? if ($pageCount > 1) :?>
	<?= $this->paginationControl($this->viewParams['paginator'], 'Sliding', '/modules/common/views/scripts/commonTheme/commonLang/common/clu-pagination-control.phtml',
							    array('searchUrl' => $this->viewParams['searchUrl'])); ?>
<?endif ?>
</div>

<!--  Viewing page number X... -->
<?if (strpos($sess->userPermissions, "administer place")) :?>
<div class="clear" ><br/></div>
<div  style="background-color:gray;">
	<?=t(30) ?>: 
	<select name='bulkaction' id ="bulk" >
	<?if(true): //TODO: isadmin()?>
	<option value='delete'> <?=t(31) ?> </option>
	<?endif ?>
	<option value='status'> <?=t(32) ?> </option>
	</select>
	
	<select name='changestatus' id ="changeStatus" style=" display:none">
	<option value='featured'> <?=t(33) ?> </option>
	<option value='published'> <?=t(34) ?> </option>
	<option value='queued'> <?=t(35) ?> </option>
	<option value='unpublished'> <?=t(36) ?> </option>
	<option value='deleted'> <?=t(37) ?> </option>
	</select>
	<input type="submit" value="Apply" id="bulk-submit" name="bulkPlace"/>
</div>
<?endif?>
</form>

<?else: ?>
<?=sprintf(t(144), t(701)) ?>
<?endif ?>
</div>
